package com.fc.v2.controller.admin;

import com.fc.v2.common.base.BaseController;
import com.fc.v2.mapper.auto.TSysRoleUserMapper;
import com.fc.v2.mapper.auto.TsysUserMapper;
import com.fc.v2.model.Examine;
import com.fc.v2.model.ListObject;
import com.fc.v2.model.MapObject;
import com.fc.v2.model.auto.*;
import com.fc.v2.model.custom.Service;
import com.fc.v2.model.wapper.ApplyProjectWapper;
import com.fc.v2.service.ApplyAlterService;
import com.fc.v2.service.ApplyProjectService;
import com.fc.v2.service.ExperprojectService;
import com.fc.v2.service.FinishProjectService;
import com.fc.v2.shiro.util.ShiroUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * 服务器信息Controller
 * @ClassName: ServiceController
 * @author fuce
 * @date 2019-06-23 00:55
 * @version V1.0
 */
@Api(value = "服务器信息")
@Controller
@RequestMapping("/ServiceController")
public class ServiceController extends BaseController{

	@Autowired
	private ApplyProjectService applyProjectService;

	@Autowired
	private FinishProjectService finishProjectService;

	@Autowired
	private TSysRoleUserMapper tSysRoleUserMapper;

	@Autowired
	private ApplyAlterService applyAlterService;

	@Autowired
	private TsysUserMapper tsysUserMapper;

	@Autowired
	private ExperprojectService experprojectService;



	//跳转页面参数
	private final String prefix = "admin/service";



	
	/**
	 * 展示页面
	 * @param model
	 * @return
	 * @author fuce
	 * @Date 2019年11月11日 下午4:04:03R	 */
	@ApiOperation(value = "展示页面", notes = "展示页面")
	@GetMapping("/view")
	@RequiresPermissions("system:service:view")
    public String view(ModelMap model){

		TSysRoleUserExample tSysRoleUserExample = new TSysRoleUserExample();
		tSysRoleUserExample.createCriteria().andSysUserIdEqualTo(ShiroUtils.getUserId());
		List<TSysRoleUser> tSysRoleUserList = tSysRoleUserMapper.selectByExample(tSysRoleUserExample);
		//查询项目的年份
		HashSet<Integer> years = selectYear();
		List<Integer> yearList = new ArrayList<>();
		for (Integer year:years) {
			yearList.add(year);
		}
		int newYear = Collections.max(yearList);
		for (TSysRoleUser roleUser:tSysRoleUserList) {
			if(roleUser.getSysRoleId().equals("620402700860919808") || roleUser.getSysRoleId().equals("488243256161730560")){
				ListObject applyList = applySelectSkl(newYear);
				ListObject finishList = finishSelectSkl(newYear);
				model.addAttribute("applyList",applyList);
				model.addAttribute("finishList",finishList);
				return prefix + "/listSkl";
			}else if(roleUser.getSysRoleId().equals("620402533122314240")){
				ListObject applyList = applySelectDanwei(newYear);
				ListObject finishList = finishSelectDanwei(newYear);
				model.addAttribute("applyList",applyList);
				model.addAttribute("finishList",finishList);
				return prefix + "/listDanwei";
			}else if(roleUser.getSysRoleId().equals("620402627791949824") || roleUser.getSysRoleId().equals("620402439597723648")){
				ListObject applyList = applySelectGeren(newYear);
				ListObject finishList = finishSelectGeren(newYear);
				model.addAttribute("applyList",applyList);
				model.addAttribute("finishList",finishList);
				return prefix + "/listDanwei";
			}else if(roleUser.getSysRoleId().equals("615413901659607040")){
				ListObject applyList = applySelectExpert(newYear);
				ListObject finishList = finishSelectExpert(newYear);
				model.addAttribute("applyList",applyList);
				model.addAttribute("finishList",finishList);
				return prefix + "/listDanwei";
			}
		}

		return prefix + "/empty";
    }

	/**
	 * 单位结项展示
	 * @param year
	 * @return
	 */
	public ListObject finishSelectDanwei(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		String deptName = tsysUserMapper.selectByPrimaryKey(userId).getDeptName();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		FinishProjectExample totalExample = new FinishProjectExample();
		totalExample.createCriteria().andDeptPassIn(stateList).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<FinishProject> totalList = finishProjectService.selectByExample(totalExample);

		//项目已审核数量查询条件
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		FinishProjectExample examineDoneExample = new FinishProjectExample();
		examineDoneExample.createCriteria().andDeptPassIn(examineDoneSates).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<FinishProject> examineDoneList = finishProjectService.selectByExample(examineDoneExample);

		//项目待审核数量查询条件
		FinishProjectExample needExamineExample = new FinishProjectExample();
		needExamineExample.createCriteria().andDeptPassEqualTo(Examine.NEED_EXAMINE.code).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<FinishProject> needExamineList = finishProjectService.selectByExample(needExamineExample);
		MapObject m1 = new MapObject();

		//项目总数
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		MapObject m2 = new MapObject();
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());
		list.add(m1);
		list.add(m2);
		list.add(m3);
		return list;
	}

	/**
	 * 单位立项展示
	 * @param year
	 * @return
	 */
	public  ListObject applySelectDanwei(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		String deptName = tsysUserMapper.selectByPrimaryKey(userId).getDeptName();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		//立项
		ApplyProjectExample totalExample = new ApplyProjectExample();
		totalExample.createCriteria().andDeptPassIn(stateList).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<ApplyProject> totalList = applyProjectService.selectByExample(totalExample);

		//项目已审核数量查询条件
		//立项
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		ApplyProjectExample examineDoneExample = new ApplyProjectExample();
		examineDoneExample.createCriteria().andDeptPassIn(examineDoneSates).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<ApplyProject> examineDoneList = applyProjectService.selectByExample(examineDoneExample);

		//项目待审核数量查询条件
		//立项
		ApplyProjectExample needExamineExample = new ApplyProjectExample();
		needExamineExample.createCriteria().andDeptPassEqualTo(Examine.NEED_EXAMINE.code).andDeptUpdateTimeBetween(startDate,endDate).andProDeptEqualTo(deptName);
		List<ApplyProject> needExamineList = applyProjectService.selectByExample(needExamineExample);

		//项目变更总数
		ApplyAlterExample applyAlterExample = new ApplyAlterExample();
		applyAlterExample.createCriteria().andDeptPassIn(examineDoneSates).andDeptUpdateTimeBetween(startDate,endDate).andManDeptEqualTo(deptName);
		List<ApplyAlter> applyAlterList = applyAlterService.selectByExample(applyAlterExample);

		//项目变更待审核
		ApplyAlterExample needExamineAlterExample = new ApplyAlterExample();
		needExamineAlterExample.createCriteria().andDeptPassEqualTo(Examine.NEED_EXAMINE.code).andDeptUpdateTimeBetween(startDate,endDate).andManDeptEqualTo(deptName);
		List<ApplyAlter> applyAlterNeedExamineList = applyAlterService.selectByExample(needExamineAlterExample);

		//项目变更已审核
		ApplyAlterExample doneExamineAlterExample = new ApplyAlterExample();
		doneExamineAlterExample.createCriteria().andDeptPassIn(examineDoneSates).andDeptUpdateTimeBetween(startDate,endDate).andManDeptEqualTo(deptName);
		List<ApplyAlter> doneExamineAlterList = applyAlterService.selectByExample(doneExamineAlterExample);

		MapObject m1 = new MapObject();
		//项目总数
		//立项
//		applyProjectWapperList.get(0).setProSize(totalList.size());
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		//立项
		MapObject m2 = new MapObject();
//		applyProjectWapperList.get(0).setNeedExamine(needExamineList.size());
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		//立项
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());
		//项目变更总数
		MapObject m4 = new MapObject();
		m4.put("header","项目变更总数");
		m4.put("number",applyAlterList.size());
		//项目变更待审核
		MapObject m5 = new MapObject();
		m5.put("header","项目变更待审核");
		m5.put("number",applyAlterNeedExamineList.size());
		//项目变更已审核
		MapObject m6 = new MapObject();
		m6.put("header","项目变更已审核");
		m6.put("number",doneExamineAlterList.size());
		list.add(m1);
		list.add(m2);
		list.add(m3);
		list.add(m4);
		list.add(m5);
		list.add(m6);
		return list;
	}

	/**
	 * 个人立项展示
	 * @param year
	 * @return
	 */
	public  ListObject applySelectGeren(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		//立项
		ApplyProjectExample totalExample = new ApplyProjectExample();
		totalExample.createCriteria().andManIdEqualTo(userId);
		List<ApplyProject> totalList = applyProjectService.selectByExample(totalExample);

		//项目已审核数量查询条件
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		ApplyProjectExample examineDoneExample = new ApplyProjectExample();
		examineDoneExample.createCriteria().andManIdEqualTo(userId).andProStateIn(examineDoneSates);
		List<ApplyProject> examineDoneList = applyProjectService.selectByExample(examineDoneExample);

		//项目待审核数量查询条件
		ApplyProjectExample needExamineExample = new ApplyProjectExample();
		needExamineExample.createCriteria().andManIdEqualTo(userId).andProStateEqualTo(Examine.NEED_EXAMINE.code);
		List<ApplyProject> needExamineList = applyProjectService.selectByExample(needExamineExample);

		//项目变更总数
		ApplyAlterExample applyAlterExample = new ApplyAlterExample();
		applyAlterExample.createCriteria().andManIdEqualTo(userId);
		List<ApplyAlter> applyAlterList = applyAlterService.selectByExample(applyAlterExample);

		//项目变更待审核
		ApplyAlterExample needExamineAlterExample = new ApplyAlterExample();
		needExamineAlterExample.createCriteria().andManIdEqualTo(userId).andStateEqualTo(Examine.NEED_EXAMINE.code);
		List<ApplyAlter> applyAlterNeedExamineList = applyAlterService.selectByExample(needExamineAlterExample);

		//项目变更已审核
		ApplyAlterExample doneExamineAlterExample = new ApplyAlterExample();
		doneExamineAlterExample.createCriteria().andManIdEqualTo(userId).andStateIn(examineDoneSates);
		List<ApplyAlter> doneExamineAlterList = applyAlterService.selectByExample(doneExamineAlterExample);

		MapObject m1 = new MapObject();
		//项目总数
		//立项
//		applyProjectWapperList.get(0).setProSize(totalList.size());
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		//立项
		MapObject m2 = new MapObject();
//		applyProjectWapperList.get(0).setNeedExamine(needExamineList.size());
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		//立项
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());
		//项目变更总数
		MapObject m4 = new MapObject();
		m4.put("header","项目变更总数");
		m4.put("number",applyAlterList.size());
		//项目变更待审核
		MapObject m5 = new MapObject();
		m5.put("header","项目变更待审核");
		m5.put("number",applyAlterNeedExamineList.size());
		//项目变更已审核
		MapObject m6 = new MapObject();
		m6.put("header","项目变更已审核");
		m6.put("number",doneExamineAlterList.size());
		list.add(m1);
		list.add(m2);
		list.add(m3);
		list.add(m4);
		list.add(m5);
		list.add(m6);
		return list;
	}

	/**
	 * 个人结项展示
	 * @param year
	 * @return
	 */
	public ListObject finishSelectGeren(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		FinishProjectExample totalExample = new FinishProjectExample();
		totalExample.createCriteria().andManIdEqualTo(userId);
		List<FinishProject> totalList = finishProjectService.selectByExample(totalExample);

		//项目已审核数量查询条件
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		FinishProjectExample examineDoneExample = new FinishProjectExample();
		examineDoneExample.createCriteria().andManIdEqualTo(userId).andProStateIn(examineDoneSates);
		List<FinishProject> examineDoneList = finishProjectService.selectByExample(examineDoneExample);

		//项目待审核数量查询条件
		FinishProjectExample needExamineExample = new FinishProjectExample();
		needExamineExample.createCriteria().andManIdEqualTo(userId).andProStateEqualTo(Examine.NEED_EXAMINE.code);
		List<FinishProject> needExamineList = finishProjectService.selectByExample(needExamineExample);
		MapObject m1 = new MapObject();

		//项目总数
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		MapObject m2 = new MapObject();
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());
		list.add(m1);
		list.add(m2);
		list.add(m3);
		return list;
	}


	/**
	 * 专家立项展示
	 * @param year
	 * @return
	 */
	public  ListObject applySelectExpert(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		//立项
		ExperprojectExample totalExample = new ExperprojectExample();
		totalExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("apply");
		List<Experproject> totalList = experprojectService.selectByExample(totalExample);

		//专家已审核完成数量查询条件
		ExperprojectExample examineDoneExample = new ExperprojectExample();
		examineDoneExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("apply").andCheckProcessEqualTo(Examine.EXPECT_DONE.code);
		List<Experproject> examineDoneList = experprojectService.selectByExample(examineDoneExample);

		//专家待审核数量查询条件
		ExperprojectExample needExamineExample = new ExperprojectExample();
		needExamineExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("apply").andCheckProcessEqualTo(Examine.NEED_EXAMINE.code);
		List<Experproject> needExamineList = experprojectService.selectByExample(needExamineExample);


		MapObject m1 = new MapObject();
		//项目总数
		//立项
//		applyProjectWapperList.get(0).setProSize(totalList.size());
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		//立项
		MapObject m2 = new MapObject();
//		applyProjectWapperList.get(0).setNeedExamine(needExamineList.size());
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		//立项
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());

		list.add(m1);
		list.add(m2);
		list.add(m3);
		return list;
	}
	/**
	 * 专家结项展示
	 * @param year
	 * @return
	 */
	public  ListObject finishSelectExpert(int year) {
		ListObject list = new ListObject();
		//通过当前用户id查找所在单位名称
		String userId = ShiroUtils.getUser().getId();
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year, 1, 1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year, 12, 31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.NEED_EXAMINE.code);

		//项目总数查询条件
		//结项
		ExperprojectExample totalExample = new ExperprojectExample();
		totalExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("finish");
		List<Experproject> totalList = experprojectService.selectByExample(totalExample);

		//专家已审核完成数量查询条件
		ExperprojectExample examineDoneExample = new ExperprojectExample();
		examineDoneExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("finish").andCheckProcessEqualTo(Examine.EXPECT_DONE.code);
		List<Experproject> examineDoneList = experprojectService.selectByExample(examineDoneExample);

		//专家待审核数量查询条件
		ExperprojectExample needExamineExample = new ExperprojectExample();
		needExamineExample.createCriteria().andExpertIdEqualTo(userId).andOther1EqualTo("finish").andCheckProcessEqualTo(Examine.NEED_EXAMINE.code);
		List<Experproject> needExamineList = experprojectService.selectByExample(needExamineExample);


		MapObject m1 = new MapObject();
		//项目总数
		//立项
		m1.put("header","项目总数");
		m1.put("number",totalList.size());
		//待审核数量
		//立项
		MapObject m2 = new MapObject();
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());
		//已审核数量
		//立项
		MapObject m3 = new MapObject();
		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());

		list.add(m1);
		list.add(m2);
		list.add(m3);
		return list;
	}

	/**
	 * 社科联展示页面
	 * @param model
	 * @return
	 * @author fuce
	 * @Date 2019年11月11日 下午4:04:03R	 */
	@ApiOperation(value = "展示页面", notes = "展示页面")
	@RequiresPermissions("system:service:viewSkl")
	public String viewSkl(ModelMap model)
	{
		List<ApplyProjectWapper> applyProjectWapperList = new ArrayList<>();
		model.addAttribute("projectWrapperList",applyProjectWapperList);
		return prefix + "/listSkl";
	}

	/**
	 * 社科联查询项目年份
	 */
	public HashSet<Integer> selectYear(){
		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);
		stateList.add(Examine.EXPECT_DOING.code);
		stateList.add(Examine.EXPECT_DONE.code);
		//立项的年份
		ApplyProjectExample applyProjectExample = new ApplyProjectExample();
		applyProjectExample.createCriteria().andSklPassIn(stateList);
		List<ApplyProject> applyProjectList = applyProjectService.selectByExample(applyProjectExample);
		HashSet<Integer> years = new HashSet<>();
		Calendar calendar = Calendar.getInstance();
		for (ApplyProject ap:applyProjectList) {
			if(ap.getSklUpdateTime() != null){
				calendar.setTime(ap.getSklUpdateTime());
				years.add(calendar.get(Calendar.YEAR));
			}
		}
		//结项的年份
		FinishProjectExample finishProjectExample = new FinishProjectExample();
		finishProjectExample.createCriteria().andSklPassIn(stateList);
		List<FinishProject> finishProjectList = finishProjectService.selectByExample(finishProjectExample);
		for (FinishProject fp:finishProjectList) {
			if(fp.getSklUpdateTime() != null){
				calendar.setTime(fp.getSklUpdateTime());
				years.add(calendar.get(Calendar.YEAR));
			}
		}
		return years;
	}




	/**
	 * 立项展示内容
	 * @param model
	 * @return
	 * @author fuce
	 * @Date 2019年11月11日 下午4:04:03R	 */
	@ApiOperation(value = "展示页面", notes = "展示页面")
	public ListObject applySelectSkl(int year)
	{
		ListObject list = new ListObject();
		//查询时间段
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year,1,1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year,12,31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);
		stateList.add(Examine.EXPECT_DOING.code);
		stateList.add(Examine.EXPECT_DONE.code);
		//项目总数查询条件
		//立项
		ApplyProjectExample totalExample = new ApplyProjectExample();
		totalExample.createCriteria().andSklPassIn(stateList).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyProject> totalList = applyProjectService.selectByExample(totalExample);


		//项目待审核数量查询条件
		//立项
		ApplyProjectExample needExamineExample = new ApplyProjectExample();
		needExamineExample.createCriteria().andSklPassEqualTo(Examine.NEED_EXAMINE.code).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyProject> needExamineList = applyProjectService.selectByExample(needExamineExample);



		//项目已审核数量查询条件
		//立项
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		ApplyProjectExample examineDoneExample = new ApplyProjectExample();
		examineDoneExample.createCriteria().andSklPassIn(examineDoneSates).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyProject> examineDoneList = applyProjectService.selectByExample(examineDoneExample);

		//项目专家审核中数量查询条件
		//立项
		ApplyProjectExample expertDoingExample = new ApplyProjectExample();
		expertDoingExample.createCriteria().andSklPassEqualTo(Examine.EXPECT_DOING.code).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyProject> expertDoingList = applyProjectService.selectByExample(expertDoingExample);

		//项目专家审核完成数量查询条件
		//立项
		ApplyProjectExample expertDoneExample = new ApplyProjectExample();
		expertDoneExample.createCriteria().andSklPassEqualTo(Examine.EXPECT_DONE.code).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyProject> expertDoneList = applyProjectService.selectByExample(expertDoneExample);

		//项目变更查询
		ApplyAlterExample applyAlterExample = new ApplyAlterExample();
		applyAlterExample.createCriteria().andSklPassEqualTo(Examine.NEED_EXAMINE.code).andSklUpdateTimeBetween(startDate,endDate);
		List<ApplyAlter> applyAlterList = applyAlterService.selectByExample(applyAlterExample);

		MapObject m1 = new MapObject();
		//项目总数
		//立项
//		applyProjectWapperList.get(0).setProSize(totalList.size());
		m1.put("header","项目总数");
		m1.put("number",totalList.size());


		//待审核数量
		//立项
		MapObject m2 = new MapObject();
//		applyProjectWapperList.get(0).setNeedExamine(needExamineList.size());
		m2.put("header","待审核");
		m2.put("number",needExamineList.size());


		//已审核数量
		//立项
		MapObject m3 = new MapObject();

		m3.put("header","已审核");
		m3.put("number",examineDoneList.size());


		//专家审核中数量
		//立项
		MapObject m4 = new MapObject();
//		applyProjectWapperList.get(0).setExpertDoing(expertDoingList.size());
		m4.put("header","专家审核中");
		m4.put("number",expertDoingList.size());
;

		//专家审核完成数量
		//立项
		MapObject m5 = new MapObject();
//		applyProjectWapperList.get(0).setExpertDone(examineDoneList.size());
		m5.put("header","专家审核完成");
		m5.put("number",(examineDoneList.size()));

		//项目变更数量
		//立项
		MapObject m6 = new MapObject();
//		applyProjectWapperList.get(0).setExpertDone(examineDoneList.size());

		m6.put("header","项目变更待审核");
		m6.put("number",(applyAlterList.size()));


		list.add(m1);
		list.add(m2);
		list.add(m3);
		list.add(m4);
		list.add(m5);
		list.add(m6);


		return list;
	}

	/**
	 * 结项展示内容
	 * @param model
	 * @return
	 * @author fuce
	 * @Date 2019年11月11日 下午4:04:03R	 */
	@ApiOperation(value = "展示页面", notes = "展示页面")
	public ListObject finishSelectSkl(int year)
	{
		ListObject list = new ListObject();
		//查询时间段
		//开始时间
		Calendar startCalendar = Calendar.getInstance();
		startCalendar.set(year,1,1);
		Date startDate = startCalendar.getTime();
		//结束时间
		Calendar endCalendar = Calendar.getInstance();
		endCalendar.set(year,12,31);
		Date endDate = endCalendar.getTime();

		//项目状态
		List<Integer> stateList = new ArrayList<>();
		stateList.add(Examine.PASSED.code);
		stateList.add(Examine.BANNED.code);
		stateList.add(Examine.NEED_EXAMINE.code);
		stateList.add(Examine.EXPECT_DOING.code);
		stateList.add(Examine.EXPECT_DONE.code);
		//项目总数查询条件

		//结项
		FinishProjectExample totalFinishExample = new FinishProjectExample();
		totalFinishExample.createCriteria().andSklPassIn(stateList).andSklUpdateTimeBetween(startDate,endDate);
		List<FinishProject> totalFinishList = finishProjectService.selectByExample(totalFinishExample);

		//项目待审核数量查询条件

		//结项
		FinishProjectExample needExamineFinishExample = new FinishProjectExample();
		needExamineFinishExample.createCriteria().andSklPassEqualTo(Examine.NEED_EXAMINE.code).andSklUpdateTimeBetween(startDate,endDate);
		List<FinishProject> needExamineFinishList = finishProjectService.selectByExample(needExamineFinishExample);


		//项目已审核数量查询条件

		//结项
		List<Integer> examineDoneSates = new ArrayList<>();
		examineDoneSates.add(Examine.PASSED.code);
		examineDoneSates.add(Examine.BANNED.code);
		FinishProjectExample examineDoneFinishExample = new FinishProjectExample();
		examineDoneFinishExample.createCriteria().andSklPassIn(examineDoneSates).andSklUpdateTimeBetween(startDate,endDate);
		List<FinishProject> examineDoneFinishList = finishProjectService.selectByExample(examineDoneFinishExample);

		//项目专家审核中数量查询条件

		//结项
		FinishProjectExample expertDoingFinishExample = new FinishProjectExample();
		expertDoingFinishExample.createCriteria().andSklPassEqualTo(Examine.EXPECT_DOING.code).andSklUpdateTimeBetween(startDate,endDate);
		List<FinishProject> expertDoingFinishList = finishProjectService.selectByExample(expertDoingFinishExample);

		//项目专家审核完成数量查询条件

		//结项
		FinishProjectExample expertDoneFinishExample = new FinishProjectExample();
		expertDoneFinishExample.createCriteria().andSklPassEqualTo(Examine.EXPECT_DONE.code).andSklUpdateTimeBetween(startDate,endDate);
		List<FinishProject> expertDoneFinishList = finishProjectService.selectByExample(expertDoneFinishExample);






		//项目总数
		//立项

		//结项
		MapObject m6 = new MapObject();
		m6.put("header","项目总数");
		m6.put("number",totalFinishList.size());


		//待审核数量

		//结项
		MapObject m7 = new MapObject();
//		applyProjectWapperList.get(1).setNeedExamine(needExamineFinishList.size());
		m7.put("header","待审核");
		m7.put("number",needExamineFinishList.size());

		//已审核数量

		//结项
		MapObject m8 = new MapObject();
//		applyProjectWapperList.get(1).setExamineDone(examineDoneFinishList.size());
		m8.put("header","已审核");
		m8.put("number",examineDoneFinishList.size());

		//专家审核中数量

		//结项
		MapObject m9 = new MapObject();
//		applyProjectWapperList.get(1).setExpertDoing(expertDoingFinishList.size());
		m9.put("header","专家审核中");
		m9.put("number",expertDoingFinishList.size());

		//专家审核完成数量

		//结项
		MapObject m10 = new MapObject();
//		applyProjectWapperList.get(1).setExpertDone(examineDoneFinishList.size());
		m10.put("header","专家审核完成");
		m10.put("number",examineDoneFinishList.size());

		//结项
		MapObject m11 = new MapObject();
//		applyProjectWapperList.get(1).setExpertDone(examineDoneFinishList.size());
		m11.put("header","证书总数");
		m11.put("number",examineDoneFinishList.size());


		list.add(m6);
		list.add(m7);
		list.add(m8);
		list.add(m9);
		list.add(m10);
		list.add(m11);
//		model.addAttribute("projectWrapperList",applyProjectWapperList);
		return list;
	}



}
